<!-- 物资领用添加 -->
<template>
  <div>
    <h2>基本信息</h2>
    <el-form ref="form"  :model="form" label-width="80px">
      <el-form-item label="标题" prop="goodsTitle">
        <el-input v-model="form.goodsTitle" placeholder="请输入标题"></el-input>
      </el-form-item>
      <el-form-item label="用途描述" prop="useInfo">
        <el-input v-model="form.useInfo"></el-input>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark"></el-input>
      </el-form-item>
      <el-form-item label="选择领用物品" prop="goodsItem">
        <el-select
          v-model="form.goodsItem"
          placeholder="请选择物品"
          style="float: left"
        >
          <el-option label="轮胎" value="1"></el-option>
          <el-option label="订书机" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit(form)">提交</el-button>
        <el-button type="Danger" @click="QXCollectionFrom">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>


<script>
import axios from "axios";
export default {
  data() {
    return {
      form: {
        goodsTitle :"",
        useInfo   :"",
        goodsItem:"",
        remark    :"",
      },
      rules: {
        goodsTitle: [{
          required: true,
          message: '请输入标题',
          trigger: 'blur'
        }],
        goodsItem: [{
          required: true,
          message: '请输入物品',
          trigger: 'blur'
        }],
        useInfo: [{
          required: false,
          message: '请输入用途',
          trigger: 'blur'
        }],
        remark: [{
          required: false,
          message: '请输入备注',
          trigger: 'blur'
        }],
      },
    };
  },
  methods: {
    onSubmit(form) {
      this.axios({
        url: "https://localhost:44331/api/app/cargo_Information/cargo",
        method: "post",
        data: form,
      }).then((res) => {
        if (res.status == 200) {
          this.$message.success("添加成功");
          this.$router.push("/Show/Goods_Receiving");
        } else {
          this.$message.error("添加失败");
          this.reload(); //局部刷新
        }
      });
    },
    QXCollectionFrom() {
      this.$router.push("/Show/Goods_Receiving");
    },
  },
};
</script>
